package blocks {
	
	import blocks.Door;
	
	import org.flixel.FlxG;
	import org.flixel.FlxTilemap;
	
	public class Trigger extends DynamicBlock {
		
		public var linkedDoors:Array;
		
		public function Trigger(X:int, Y:int, infos:Object, mapName:String) {
			super(X, Y, infos, mapName);
			
			linkedDoors = [];
		}
		
		public function switchTrigger():void {
			switchTile(false);
			
			for each(var bloc:* in Registry.solidTilesPool.members) {
				if(bloc is FlxTilemap) {}
				else if(bloc._triggerName && bloc._triggerName == name ){
					bloc.activate();
				}
			}
			if(sound) sound.play();
			active=false;
		}
		
		override public function update():void{
			if(Registry.gameInfos.controls.actionKey && FlxG.keys.justPressed(Registry.gameInfos.controls.actionKey)){
				switchTrigger();
			}
			active=false;
		}
		
	}
}
